import Mock from 'mockjs'

const List = []
const count = 100

for (let i = 0; i < count; i++) {
    List.push(Mock.mock({
        'id': '@increment',
        'name': '@cname',
        'tel': '@integer(10000)',
        'date': '@date("yyyy-MM-dd")',
        'datetime': '@datetime("yyyy-MM-dd HH:mm:ss")',
    }))
}
export default [
    {
        url: '/ser/getTestList',
        type: 'post',
        response: config => {
            const { name, tel, page = 1, pageSize = 10 } = config.query
            const mockList = List.filter(item => {
                if (name && item.name.indexOf(name) < 0) return false
                if (tel && item.tel.indexOf(tel) < 0) return false
                return true
            })

            const pageList = mockList.filter((item, index) => index < pageSize * page && index >= pageSize * (page - 1))
            return {
                msg: '获取成功!',
                flag: true,
                code: 20000,
                data: {
                    flag: true,
                    items: pageList,
                    total: mockList.length
                }
            }
        }
    },


]
